/*
 * Copyright 2000 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _WT_IN_PROC_SESSION_H
#define _WT_IN_PROC_SESSION_H

#include <tcl.h>

typedef struct WtProcSessionT {
  Tcl_Obj *id;
  int isAutoId;
  int isOpen;
  int isModified;
} WtProcSession;

typedef struct WtProcSessionStorageT {
  Tcl_Obj *id;
  Tcl_Obj *mtTable;
  time_t accessTime;
} WtProcSessionStorage;

int WtInitProcSessionId(WtProcSession *ps, Tcl_Interp *interp);
Tcl_Obj *WtGetProcSessionId(WtProcSession *ps, Tcl_Interp *interp);
int WtSetProcSessionId(WtProcSession *ps, Tcl_Obj *id, Tcl_Interp *interp);
int WtOpenProcSession(WtProcSession *ps, Tcl_Interp *interp);
int WtCloseProcSession(WtProcSession *ps, Tcl_Interp *interp);
int WtDeleteProcSession(WtProcSession *ps, Tcl_Obj *id, Tcl_Interp *interp);
int WtSweepProcSessions(WtProcSession *ps, Tcl_Interp *interp);
int WtProcSessionFinalizeRequest(WtProcSession *ps, Tcl_Interp *interp);
WtProcSessionStorage *WtGetProcSessionStorage(WtProcSession *ps,
  Tcl_Interp *interp);
void WtReleaseProcSessionStorage(WtProcSessionStorage *st, Tcl_Interp *interp);
int WtProcSessionCmd(ClientData clientData, Tcl_Interp *interp,
  int objc, Tcl_Obj *const objv[]);
int WtProcSessionCmdHelper(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
WtProcSessionCmdUsage(Tcl_Interp *interp, Tcl_Obj *cmd);
int WtProcSessionIdCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionCountCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionHasCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionGetCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionSetCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionSetDefaultCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionKeysCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionValuesCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionRemoveCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionRemoveListCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionArrayCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionItemsCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionClearCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionIsAccessedCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionIsModifiedCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionTouchCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionStatusCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionPropertiesCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionDeleteCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionSweepCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionLoadModuleCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionUnloadModuleCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
int WtProcSessionFinalizeCmd(ClientData clientData, Tcl_Interp *interp,
  WtProcSession *ps, int objc, Tcl_Obj *const objv[]);
void WtInitProcSessionCommands(Tcl_Interp *interp);
Tcl_Obj *WtNewProcSessionObj();
WtProcSession *WtProcSessionRep(Tcl_Obj *obj);

extern Tcl_ObjType WtProcSessionType;
extern Tcl_HashTable *wtProcSessions;
extern Tcl_Mutex wtProcSessionsLock;

#endif /* !_WT_IN_PROC_SESSION_H */
